#pragma once

#include "Main.h"

#include "InputKeys.h"

static const u_int uINPUT_TEXTBUFFER_SIZE = SDL_TEXTINPUTEVENT_TEXT_SIZE;

class Input
{
	public:

		Input();
		~Input();

		void	SwapInputBuffers ();

		bool	MouseButtonPressed			( const INPUT_MOUSE_BUTTON xButton ) const;
		bool	MouseButtonDoubleClick		( const INPUT_MOUSE_BUTTON xButton ) const;
		//bool	MouseButtonDoubleRightClick	( const INPUT_MOUSE_BUTTON xButton ) const;
		bool	MouseButtonHeld				( const INPUT_MOUSE_BUTTON xButton ) const;
		bool	MouseButtonReleased			( const INPUT_MOUSE_BUTTON xButton ) const;

		bool	KeyPressed( const INPUT_KEY xKey ) const;	// Debounced
		bool	KeyDown( const INPUT_KEY xKey ) const;
		bool	KeyHeld( const INPUT_KEY xKey ) const;
		bool	KeyReleased( const INPUT_KEY xKey ) const;

        const char*   GetTextInputBuffer() const { return m_szTextInputBuffer; }

		bool	MouseMoved					( ) const;
		u_int	MousePositionX				( ) const;
		u_int	MousePositionY				( ) const;

		void	FlushInput					( );

		void	HandleEvent					( const SDL_Event& xEvent );
	
		static void	SetCursor				( const INPUT_MOUSE_CURSOR xCursor );
	
	private:

		bool m_abCurrentKeyInput	[INPUT_NUM_KEYS];
		bool m_abPreviousKeyInput	[INPUT_NUM_KEYS];

		bool m_abCurrentMouseInput	[INPUT_MOUSE_NUM_BUTTONS];
		bool m_abPreviousMouseInput	[INPUT_MOUSE_NUM_BUTTONS];

		u_int m_uMousePositionX;
		u_int m_uMousePositionY;

		u_int m_uPreviousMousePositionX;
		u_int m_uPreviousMousePositionY;

        char m_szTextInputBuffer[uINPUT_TEXTBUFFER_SIZE];
	
		static float s_fClickRepeatTimer;

		static void Platform_SetCursor( const INPUT_MOUSE_CURSOR xCursor );
};

// _______________________________________________________________________________

static const int iCLIPBOARD_DATA_SIZE = 1024 * 50;

class Clipboard
{
	public:
	
		static void Initialise();
		static void Shutdown();

		static void CopyToClipboard( const char* szText, u_int uLen = (u_int)iCLIPBOARD_DATA_SIZE );
		static const char* GetClipboardData();

	private:

		static void Platform_Copy();
		static void Platform_Paste();
		

		static char* s_szClipboard;
};

//eof
